﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Akso.Courses.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Akso.Web.Areas.EduAdminModule.Models.Courses
{
    /// <summary>
    /// 在查询页面中，传递给页面的ViewModel对象，只包含查询条件，不包括任何数据。
    /// </summary>
    public class CoursesViewModel
    {
        public string FilterText { get; set; }
        /// <summary>
        /// 课程所属期限
        /// </summary>
        //public List<ComboboxItemDto> GetCourseTermList { get; set; }
    }
    [AutoMapFrom(typeof(GetCourseForEditOutput))]
    public class CreateOrEditCourseModalViewModel : GetCourseForEditOutput
    {
        public bool IsEditMode
        {
            get { return Course.Id.HasValue; }
        }
        public bool IsDisable
        {
            get { return Course.IsDisable; }
        }
        /// <summary>
        /// 年份
        /// </summary>
        public IList<SelectListItem> GetYearList { get; set; }
        /// <summary>
        /// 课程所属期限
        /// </summary>
        public List<ComboboxItemDto> GetCourseTermList { get; set; }
        /// <summary>
        /// 课程所属班级
        /// </summary>
        public List<ComboboxItemDto> GetCourseGradeList { get; set; }
        /// <summary>
        /// 课程所属科目
        /// </summary>
        public List<ComboboxItemDto> GetCourseSubjectList { get; set; }
        /// <summary>
        /// 课程所属类型
        /// </summary>
        public List<ComboboxItemDto> GetCourseTypeList { get; set; }
        //枚举就是这么用的-计费方式
        public Akso.Enums.EnumCollection.EnumChargeType ChargeTypeList { get; set; }
        /// <summary>
        /// 生成年份
        /// </summary>
        public void GenerateYears()
        {
            IList<SelectListItem> yearList = new List<SelectListItem>();
            int year = DateTime.Now.Year;
            for(int i=year;i>year-10;i--)
            {
                yearList.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString() });
            }
            GetYearList = yearList;
        }
       
        public CreateOrEditCourseModalViewModel(GetCourseForEditOutput output)
        {
            GenerateYears();
            output.MapTo(this);
        }
    }
}